/*************************************
 * Created by WebStorm
 * Author : 艾尼亚尔·毛拉吾提
 * QQ : 524155792  WeChat : ainiyar0124
 * Created Time :2024/2/6 13:35
 Desc :
 **************************************/
import {provide, inject, Ref, ComputedRef} from 'vue';
import {TableActionType} from '../types/Table.ts';
import {DataTableProps} from 'naive-ui';

const key = Symbol('data-tables-content');

type Instance = TableActionType & {
    wrapRef: Ref<Nullable<HTMLElement>>;
    getBindValues: ComputedRef<Recordable>;
};
type RetInstance = Omit<Instance, "getBindValues"> & {
    getBindValues: ComputedRef<DataTableProps>;
};
export function createTableContext(instance: Instance) {
    provide(key, instance);
}
export function useTableContext(): RetInstance {
    return inject(key) as RetInstance;
}